<?php
    /**
     * Created by PhpStorm.
     * User: walker
     * Date: 2019/10/22
     * Time: 17:26
     */

    function ajaxReturn($code, $msg = '', $data = [])
    {
        header('Content-type: application/json');
        $arr = [
            'status_code' => $code,
            'message'  => $msg,
            'data' => $data,
        ];
        echo json_encode($arr, true);
        die();
    }

    function toArr($object)
    {
        //先编码成json字符串，再解码成数组
        return json_decode(json_encode($object), true);
    }
